﻿using System;

namespace GLib
{
    public class SharedMem
    {
        public const uint INIT_SIZE = 1024;

        public uint _size = INIT_SIZE;

        byte[] m_pMem;

        public SharedMem()
        {
            m_pMem = new byte[_size];
        }

        public byte[] CreateBuffer(int size)
        {
            if( size > _size )
            {
                m_pMem = null;
                _size = _size * 2;
                while (size > _size)
                {
                    _size = _size * 2;
                }
                m_pMem = new byte[_size];
            }
            Array.Clear(m_pMem, 0, (int)_size);
            return m_pMem;
        }
    }
}
